using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using WHC.Hotel.Entity;
using WHC.Hotel.IDAL;
using WHC.OrderWater.Commons;

namespace WHC.Hotel.DAL
{
	/// <summary>
	/// TeaSuiteType 的摘要说明。
	/// </summary>
	public class TeaSuiteType : BaseDAL<TeaSuiteTypeInfo>, ITeaSuiteType
	{
		#region 对象实例及构造函数

		public static TeaSuiteType Instance
		{
			get
			{
				return new TeaSuiteType();
			}
		}
		public TeaSuiteType() : base("CL_TeaSuiteType","ID")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override TeaSuiteTypeInfo DataReaderToEntity(IDataReader dataReader)
		{
			TeaSuiteTypeInfo teaSuiteTypeInfo = new TeaSuiteTypeInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			teaSuiteTypeInfo.ID = reader.GetInt32("ID");
			teaSuiteTypeInfo.Name = reader.GetString("Name");
			teaSuiteTypeInfo.AtLeaseMoney = reader.GetDecimal("AtLeaseMoney");
			teaSuiteTypeInfo.CaculateType = reader.GetString("CaculateType");
            teaSuiteTypeInfo.Price = reader.GetDecimal("Price");
			teaSuiteTypeInfo.Persons = reader.GetInt32("Persons");
			teaSuiteTypeInfo.Note = reader.GetString("Note");
            teaSuiteTypeInfo.BuyOutPrice = reader.GetDecimal("BuyOutPrice");
			
			return teaSuiteTypeInfo;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(TeaSuiteTypeInfo obj)
		{
		    TeaSuiteTypeInfo info = obj as TeaSuiteTypeInfo;
			Hashtable hash = new Hashtable(); 
			
 			hash.Add("Name", info.Name);
 			hash.Add("AtLeaseMoney", info.AtLeaseMoney);
 			hash.Add("CaculateType", info.CaculateType);
            hash.Add("Price", info.Price);
 			hash.Add("Persons", info.Persons);
 			hash.Add("Note", info.Note);
            hash.Add("BuyOutPrice", info.BuyOutPrice);
 				
			return hash;
		}

        public TeaSuiteTypeInfo FindByName(string name)
        {
            string condition = string.Format("Name='{0}' ", name);
            return FindSingle(condition);
        }
    }
}